﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using Maticsoft.Common;
using BarberShop.BLL;

public partial class index : BasePage
    {
        string filepath = "";
        public string _content = "";
      
        protected void Page_Load(object sender, EventArgs e)
        {
            filepath = ConfigHelper.GetConfigString("Noticfile");
            if (!IsPostBack)
            {
                BandStoresinfo();
                loaddata();
            }

        }

        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_save_Click(object sender, EventArgs e)
        {
            string notic = Request.Form["text_content"];
            string filename = string.Format("gonggao_{0}.txt", this.drp_store.SelectedValue);
            FileHelper.CreateFile(filepath,filename, StringPlus.Str2Arr(notic));
            loaddata();
        }

        /// <summary>
        /// 载入数据
        /// </summary>
        protected void loaddata()
        {
            string filename = string.Format("gonggao_{0}.txt", this.drp_store.SelectedValue);
            long length=0;
            _content = FileHelper.GetFileContent(filepath + filename,out length);
        }

        #region 绑定门店
        public void BandStoresinfo()
        {
            this.drp_store.DataSource = StoresInfoBLL.GetStoresList(new BarberShop.Model.StoresInfoSearch());
            this.drp_store.DataTextField = "StoreName";
            this.drp_store.DataValueField = "ID";
            this.drp_store.DataBind();
        }
        #endregion

        protected void drp_store_SelectedIndexChanged(object sender, EventArgs e)
        {
            loaddata();
        }
    }